#include "PlanVol.h"
#include "DegToXY.h"
#include <string.h>

PlanVol::PlanVol(){}

// constructeur avec parametres
PlanVol::PlanVol(int id,char* dep,float latDep,float longDep,int h_dep,char* arr,float latArr,float longArr,int h_arr,int nivo){
  idVol = id;

  int i;
  for (i=0; i<4; i++)
    {
      idAeroportDeDepart[i] = dep[i];
    }
  idAeroportDeDepart[i] = '\0';

  latitudeAeroportDeDepart = latDep;
  longitudeAeroportDeDepart = longDep;
  heureDeDepart = h_dep;
  
  for (i=0; i<4; i++)
    {
      idAeroportDArrivee[i] = arr[i];
    }
  idAeroportDArrivee[i] = '\0';

  latitudeAeroportDArrivee = latArr;
  longitudeAeroportDArrivee = longArr;
  heureDArrivee = h_arr;
  niveauDeVol = nivo;

  // coordonnees cartesiennes
  DegToXY dtxy;
  std::vector<double> vXY = dtxy.convertiDegDecToXY(longDep,latDep);
  std::vector<double>::iterator it = vXY.begin();
  coordXDepart = (float)(*(it++));
  coordYDepart = (float)(*it);
  
  vXY = dtxy.convertiDegDecToXY(longArr,latArr);
  it = vXY.begin();
  coordXArrivee = (float)(*it++);
  coordYArrivee = (float)(*it);
 }

/*
  PlanVol& PlanVol::operator=(const PlanVol& pv)
  {
  
  printf("Dans le constructeur de recopie\n");
  idVol = pv.idVol;
  idAeroportDeDepart = pv.idAeroportDeDepart;
  latitudeAeroportDeDepart = pv.latitudeAeroportDeDepart;
  longitudeAeroportDeDepart = pv.longitudeAeroportDeDepart;
  heureDeDepart = pv.heureDeDepart;
  idAeroportDArrivee = pv.idAeroportDArrivee;
  latitudeAeroportDArrivee = pv.latitudeAeroportDArrivee;
  longitudeAeroportDArrivee = pv.longitudeAeroportDArrivee;
  heureDArrivee = pv.heureDArrivee;
  niveauDeVol = pv.niveauDeVol;  
  return *this;
  }
*/

int PlanVol::getIdVol(){return idVol;}
void PlanVol::setIdVol(int id){idVol = id;}

char* PlanVol::getIdAeroportDeDepart(){return idAeroportDeDepart;}
void PlanVol::setIdAeroportDeDepart(char* idadd){
  int i;
  for (i=0; i<4; i++)
    {
      idAeroportDeDepart[i] = idadd[i];
    }
  idAeroportDeDepart[i] = '\0';
}

float PlanVol::getLatitudeAeroportDeDepart(){return latitudeAeroportDeDepart;}
void PlanVol::setLatitudeAeroportDeDepart(float latDep){latitudeAeroportDeDepart = latDep;}

float PlanVol::getLongitudeAeroportDeDepart(){return longitudeAeroportDeDepart;}
void PlanVol::setLongitudeAeroportDeDepart(float longDep){longitudeAeroportDeDepart = longDep;}

int PlanVol::getHeureDeDepart(){return heureDeDepart;}
void PlanVol::setHeureDeDepart(int hdd){heureDeDepart = hdd;}

char* PlanVol::getIdAeroportDArrivee(){return idAeroportDArrivee;}
void PlanVol::setIdAeroportDArrivee(char* idarr){
  int i;
  for (i=0; i<4; i++)
    {
      idAeroportDArrivee[i] = idarr[i];
    }
  idAeroportDArrivee[i] = '\0';
}

float PlanVol::getLatitudeAeroportDArrivee(){return latitudeAeroportDArrivee;}
void PlanVol::setLatitudeAeroportDArrivee(float latArr){latitudeAeroportDArrivee = latArr;}

float PlanVol::getLongitudeAeroportDArrivee(){return longitudeAeroportDArrivee;}
void PlanVol::setLongitudeAeroportDArrivee(float longArr){longitudeAeroportDArrivee = longArr;}

int PlanVol::getHeureDArrivee(){return heureDArrivee;}
void PlanVol::setHeureDArrivee(int harr){heureDArrivee = harr;}

int PlanVol::getNiveauDeVol(){return niveauDeVol;}
void PlanVol::setNiveauDeVol(int nivo){niveauDeVol = nivo;}

void PlanVol::afficher()
{
  printf("idVol: %d\n",idVol);
  printf("idAeroportDeDepart: %s\n",idAeroportDeDepart);
  printf("latitudeAeroportDeDepart: %.4f\n",latitudeAeroportDeDepart);
  printf("longitudeAeroportDeDepart: %.4f\n",longitudeAeroportDeDepart);
  printf("heureDeDepart: %d\n",heureDeDepart);  
  printf("idAeroportDArrivee: %s\n",idAeroportDArrivee);
  printf("latitudeAeroportDArrivee: %.4f\n",latitudeAeroportDArrivee);
  printf("longitudeAeroportDArrivee: %.4f\n",longitudeAeroportDArrivee);
  printf("heureDArrivee: %d\n",heureDArrivee);  
  printf("niveauDeVol: %d\n",niveauDeVol);
}

// coord cartesiennes
float PlanVol::getCoordXDepart(){return coordXDepart;}
void PlanVol::setCoordXDepart(float X){coordXDepart = X;}
float PlanVol::getCoordYDepart(){return coordYDepart;}
void PlanVol::setCoordYDepart(float Y){coordYDepart = Y;}

float PlanVol::getCoordXArrivee(){return coordXArrivee;}
void PlanVol::setCoordXArrivee(float X){coordXArrivee = X;}
float PlanVol::getCoordYArrivee(){return coordYArrivee;}
void PlanVol::setCoordYArrivee(float Y){coordYArrivee = Y;}



PlanVol::~PlanVol()
{
}
